{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=225
  Verdict: Accepted
}
{$APPTYPE CONSOLE}
{$R+,S+,Q+,I+,O-}
uses SysUtils;
var i,n,k,min:longint;  a:array[1..1001] of longint;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(n);
fillchar(a,sizeof(a),0);
for i:=1 to n do read(a[i]);
read(k);
min:=1000001;
for i:=1 to n do if abs(k-a[i])<abs(k-min) then min:=a[i];
writeln(min);
end.